package com.jojo.store.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jojo.store.entity.District;
import com.jojo.store.mapper.DistrictMapper;
import com.jojo.store.service.IDistrictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class DistrictServiceImpl implements IDistrictService {
    @Autowired
    private DistrictMapper districtMapper;
    @Override
    public List<District> getBy(String parent) {
        List<District> Dlist = districtMapper.selectList(new QueryWrapper<District>().eq("parent", parent));
        for (District d : Dlist) {
            d.setId(0);
            d.setParent(null);
        }
        return Dlist;
    }

    @Override
    public String getByCode(String code) {
       return districtMapper.selectName(code);
    }
}
